const userModel = require('../model/adminUsersModel.js');
const categoriesModel = require('../model/categoriesModel');
module.exports = {
  getIndex (req,res){
      res.render('index');
  },
  getAdminIndex(req,res){
    // console.log(req.session);
    if(req.session.isLogin){
      res.render('admin/index');
    }else{
      res.send('<script>location.href="/admin/login"</script>');
    }
  },
  getAdminCategories (req,res){
    categoriesModel.getAdminCategories((err,result)=>{
      if(err) console.error(err);
      res.render('admin/categories',{arr:result});
    });
  },
  getAdminComments (req,res){
    res.render('admin/comments');
  },
  getAdminPostAdd (req,res){
    res.render('admin/post-add');
  },
  getAdminPosts (req,res){
    res.render('admin/posts');
  },
  getAdminUsers (req,res){
    userModel.getAllUser((err,result)=>{
     if(err) console.error(err);
    //  console.log(result);
     res.render('admin/users',{arr:result});
    });
  },
  getAdminLogin (req,res){
    res.render('admin/login');
  },
  getAdminProfile (req,res){
    res.render('admin/profile');
  },
}